package io.zhifei.modules.sys.system.controller.mebmer;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.*;
import io.zhifei.common.utils.PageUtils;
import io.zhifei.common.utils.R;
import io.zhifei.modules.sys.system.controller.AbstractController;
import io.zhifei.modules.sys.system.form.customer.CustomerResult;
import io.zhifei.modules.sys.system.form.member.SysMemberFollowParam;
import io.zhifei.modules.sys.system.form.member.SysMemberFollowResult;
import io.zhifei.modules.sys.system.service.member.SysMemberFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 学员跟进控制器
 *
 * @author duke
 * @Date 2020-12-21 09:24:31
 */
@CrossOrigin //跨域
@RestController
@RequestMapping("/sys/memberFollow")
@Api(value = "学员跟进Controller",tags = "学员跟进管理")
public class SysMemberFollowController extends AbstractController {


    @Resource
    private SysMemberFollowService followService;

    /**
     * 新增接口
     *
     * @author duke
     * @Date 2020-12-21
     */
    @PutMapping("/addItem")
    @ApiOperation(value = "新增学员跟进",httpMethod = "PUT")
    public R addItem(SysMemberFollowParam followParam) {
        followParam.setCreateTime(new Date());
        followParam.setFId(getUserId());
        this.followService.add(followParam);
        return R.ok();
    }


    /**
     * 删除接口
     *
     * @author duke
     * @Date 2020-12-21
     */
    @DeleteMapping("/delete")
    @ApiOperation(value = "删除学员跟进",httpMethod = "DELETE")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "学员跟进ID",required = true)
    })
    public R delete(@ApiIgnore SysMemberFollowParam followParam) {
        followParam.setUpdateTime(new Date());
        followParam.setFlag(1);
        this.followService.update(followParam);
        return R.ok();
    }


    /**
     * 获取学员跟进信息分页列表
     *
     * @author duke
     * @Date 2020-12-21
     */
    @GetMapping("/getPageList")
    @ApiOperation(value = "获取学员跟进信息分页列表", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页", required = true),
            @ApiImplicitParam(name = "pageSize", value = "当前页大小", required = true),
            @ApiImplicitParam(name = "memId",value = "学员ID"),
            @ApiImplicitParam(name = "classId",value = "班级ID"),
            @ApiImplicitParam(name = "time",value = "跟进时间"),
            @ApiImplicitParam(name = "timeType",value = "时间类型，1、具体时间，2、统计时间")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功", response = SysMemberFollowResult.class)
    })
    public R getPageList(@ApiIgnore Integer page, @ApiIgnore Integer pageSize, @ApiIgnore SysMemberFollowParam followParam) {
        PageUtils pageList = this.followService.getPageList(new Page(page,pageSize),followParam);
        return R.ok().put("data",pageList);
    }

    /**
     * 获取跟进信息查看统计列表
     * @param time 日期
     * @return
     */
    @GetMapping("/getTotalList")
    @ApiOperation(value = "获取跟进信息查看统计列表", httpMethod = "GET")
    public R getTotalList(String time){
        return this.followService.getTotalList(time);
    }

}


